<?php

class CacheController extends Zend_Controller_Action {


    public function indexAction() 
    {
        $offset     = intval($this->_request->getParam('offset', 0));
        $rowMaxID   = intval($this->_request->getParam('maxid', 1447565));
        

        //push job
        $jobParams = array();
        $jobParams['class']     = 'JobAsync';
        $jobParams['function']  = 'writeCache';
        $jobParams['args']      = array(
            'offset'    => $offset,
            'maxid'     => $rowMaxID
        );

        //Create job client
        $jobClient = Fpt_Global::getJobClientInstance('sport');

        //Register job
        $rs = $jobClient->doBackgroundTask(Fpt_Global::getJobFunction('sport', 'write_cache'), $jobParams);
        
    }
    
    public function delAction() 
    {
        $offset     = intval($this->_request->getParam('offset', 0));
        $rowMaxID   = intval($this->_request->getParam('maxid', 1447565));
        

        //push job
        $jobParams = array();
        $jobParams['class']     = 'JobAsync';
        $jobParams['function']  = 'deleteCache';
        $jobParams['args']      = array(
            'offset'    => $offset,
            'maxid'     => $rowMaxID
        );

        //Create job client
        $jobClient = Fpt_Global::getJobClientInstance('sport');

        //Register job
        $rs = $jobClient->doBackgroundTask('sport_del_cache', $jobParams);
        
    }
    
    
    public function addmaxAction()
    {
        $news = News::getInstance();
        $maxID          = $news->getMaxArticle();
        $newsRedis = Fpt_Business_News_Adapter_Redis::getInstance();
        $rs = $newsRedis->setRangeArticle($maxID);
        var_dump($maxID, $rs);die; 
    }

}